<?php
/* 
 * Lop nay dung de tao ra file translate
 */
class H_Translate_RenderArraySource{
    private $lang;
    private $langPath;
    private $scanFile;
    public function  __construct($lang,$langPath,$dirScan) {
        $this->lang = $lang;
        $this->langPath = $langPath;
        $this->scanFile = new H_Translate_Render_ScanSystem($dirScan);
    }
    public function scankeyword(){
        return $this->scanFile->getTranslateContent();
    }
    public function excesave($data){
        $string = "<?php return array(";
        foreach ($data as $key=>$keyword){
            if (empty ($keyword)) continue;
            $key = stripslashes(H_S::html($key));
            $keyword = stripslashes(H_S::html($keyword));
            $string .= "'$key' => '$keyword',\n";
        }
        $string .=");?>";      
        $path = $this->langPath."/".$this->lang.".php";
        $handle = fopen($path, "w");
        fwrite($handle, $string);
        fclose($handle);
    }
}
?>
